package com.jason.jni;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

/**
 * @author： Jason.wan
 * @date: 2022/10/27 10:39
 * @email： 1129847330@qq.com
 * @description:
 */
public class MainActivity extends AppCompatActivity {
    private static final String TAG = "jasonwan";
    private TextView tv;

    static {
        System.loadLibrary("jni");
    }

    private int num = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tv = findViewById(R.id.sample_text);
        tv.setOnClickListener(v -> {
            //setValueOfNumByJNI(num);
            //Log.d(TAG, "onClick: num=" + num);
            //tv.setText(num + "");
            Person person = new Person("jason", 30);
            try {
                jniTest();
            } catch (Throwable e) {
                e.printStackTrace();
                Log.d(TAG, "native error: " + e.getMessage());
            }
        });
    }

    public native String stringFromJNI();

    public native int getAge();

    public native void jniTest();
    //public native void jniTest(Person person);

}